# @File    : log_util.py
# @Project : JBL_Android&iOS
import logging
import os
from datetime import datetime


# class OverwriteLogHandler(logging.FileHandler):
#
#     filename = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + "\\" + "logs" + "\\" + "android_log.txt"
#
#     def __init__(self, filename=filename, mode='a'):
#         super().__init__(filename=filename, mode=mode)
#
#     def emit(self, record):
#         # 获取当前时间并格式化为字符串
#         current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
#
#         # 构造新的日志消息
#         new_message = f'[{current_time}] - [{record.levelname}] - [{record.lineno}]: {record.msg}\n'
#
#         with open(self.baseFilename, 'a', encoding='utf-8') as file:
#             file.write(new_message)
#
#
# # 创建logger对象
# logger = logging.getLogger()
# logger.setLevel(logging.INFO)
#
# # 添加自定义的文件处理器到logger中
# handler = OverwriteLogHandler()
# logger.addHandler(handler)
#
#
# def right(msg):
#     logger.info(msg)
#
#
# def warning(msg):
#     logger.warning(msg)
